package Test;

import entity.Baby;
import entity.Pet;

import entity.TypeEntity;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.junit.Test;
import service.PetService;

public class SpringTest {
//    @Test
//    public void testSpringIoC(){
//        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//        Pet pet = (Pet) context.getBean("pet");
//        pet.introduce();
//    }

    //    @Test
//    public void testService(){
//        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
//        Pet pet = (Pet) context.getBean("pet");
//        PetService petService = (PetService) context.getBean("petService");
//
//            PetService.save(pet);
//    }
    @Test
    public void testConstructorDI() {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
// 获取 baby 对象并打印介绍信息
        Baby baby = (Baby) context.getBean("redBoy");
        baby.introduce();

        TypeEntity typeEntity = (TypeEntity) context.getBean("typeEntity");
        System.out.println(typeEntity.getList());
    }
}
